package com.bootdo.lvyou_specialty.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.bootdo.lvyou_specialty.dao.LvyouSpecialtyUserAddressDao;
import com.bootdo.lvyou_specialty.domain.LvyouSpecialtyUserAddress;
import com.bootdo.lvyou_specialty.service.LvyouSpecialtyUserAddressService;
import org.springframework.transaction.annotation.Transactional;


@Service
public class LvyouSpecialtyUserAddressServiceImpl implements LvyouSpecialtyUserAddressService {
	@Autowired
	private LvyouSpecialtyUserAddressDao lvyouSpecialtyUserAddressDao;
	
	@Override
	public LvyouSpecialtyUserAddress get(Long id){
		return lvyouSpecialtyUserAddressDao.get(id);
	}
	
	@Override
	public List<LvyouSpecialtyUserAddress> list(Map<String, Object> map){
		return lvyouSpecialtyUserAddressDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return lvyouSpecialtyUserAddressDao.count(map);
	}
	
	@Override
	public int save(LvyouSpecialtyUserAddress lvyouSpecialtyUserAddress){
	
		if(lvyouSpecialtyUserAddress.getId() != null) {
			return lvyouSpecialtyUserAddressDao.update(lvyouSpecialtyUserAddress);
		}else {
			return lvyouSpecialtyUserAddressDao.save(lvyouSpecialtyUserAddress);
		}		
	
		
	}
	
	@Override
	public int update(LvyouSpecialtyUserAddress lvyouSpecialtyUserAddress){
		return lvyouSpecialtyUserAddressDao.update(lvyouSpecialtyUserAddress);
	}
	
	@Override
	public int remove(Long id){
		return lvyouSpecialtyUserAddressDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return lvyouSpecialtyUserAddressDao.batchRemove(ids);
	}

	@Override
	public List<LvyouSpecialtyUserAddress> getByUid(Long uid) {
		return lvyouSpecialtyUserAddressDao.getByUid(uid);
	}

	@Transactional
	@Override
	public int setDefault(LvyouSpecialtyUserAddress oldAddress, LvyouSpecialtyUserAddress newAddress) {
		lvyouSpecialtyUserAddressDao.update(oldAddress);
		lvyouSpecialtyUserAddressDao.update(newAddress);
		return lvyouSpecialtyUserAddressDao.update(newAddress);
	}
}
